package
{
	import com.pu3d.utils.Stats;
	
	import flash.display.Sprite;

	[SWF(width="1280", height="800", backgroundColor="#336699")]
	public class UtilsDemo extends Sprite
	{
		private var _sss:Array=[];
		public function UtilsDemo()
		{
			addChild(new Stats());
			_sss["aa"]="aa";
			_sss["bb"]="bb";
			for (var i:int = 0; i < 2; i++) 
			{
				trace(_sss.length);
				trace(_sss["aa"]);
			}
			
		}
		
		private var _queue:Array=[];
		private var _isDoing:Boolean=false;
		private var _currentObj:Object;
		public function addQueue(obj:Object,isSync:Boolean=false):void
		{
			if(isSync)
			{
				_queue.unshift(obj);
			}
			else
			{
				_queue.push(obj);
			}
			doNextExecute();
		}
		
		private function doNextExecute():void
		{
			if(!_isDoing)
			{
				_isDoing = true;
				
				_currentObj = _queue.shift();
				//_currentObj do some thing,when _currentObj execute complete,call onComplete()
			}
		}
		
		public function onComplete():void
		{
			_isDoing = false;
			//_currentObj destory;
			if(_queue.length>0)
			{
				doNextExecute();
			}
			else
			{
				//_queue execute complete;
			}
		}
	}
}